/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FingerprintForm.java
 *
 * Created on Oct 28, 2009, 11:24:00 PM
 */

package fingerprintapplication;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import Biometric.Fingerprint;
import Biometric.FingerprintGraphics;
import java.awt.image.*;
import javax.imageio.*;
import java.io.File;
import java.lang.Exception ;
import java.awt.Color;
import java.awt.event.*;
import javax.swing.JPanel;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
import javax.swing.JFrame;
/**
 *
 * @author Administrator
 */
public class FingerprintForm extends javax.swing.JFrame {
    String Ime;
public String Sifra;
 public String Broj;
    private BufferedImage bi;
public final int FP_TEMPLATE_MAX_SIZE = 601;
public double finger3[]=new double[FP_TEMPLATE_MAX_SIZE];
String aString = "78.0";
               double aDouble ;
               public String putanja;
               public String putanja2;
               public String putanja3;
    /** Creates new form FingerprintForm */
   /* public FingerprintForm() {
        initComponents();
    }*/
 class BJPanel extends JPanel
  {
    public BufferedImage bi;
    public BJPanel (){
        this.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent m){
        JOptionPane.showMessageDialog (null,"("+Integer.toString(m.getPoint().x)+";"+Integer.toString(m.getPoint().y)+")","Point",JOptionPane.PLAIN_MESSAGE);
        }
        });
    }
    public BJPanel (BufferedImage bi){
      this.bi = bi;
      setPreferredSize(new Dimension(bi.getWidth(),bi.getHeight())) ;
    }
    public void setBufferedImage(BufferedImage bi)
    {
      this.bi = bi;
      setPreferredSize(new Dimension(bi.getWidth(),bi.getHeight())) ;
      this.repaint();
    }
    public void paintComponent(Graphics g)
    {
      g.drawImage(bi,0,0,this) ;
    }
  }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jimage = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("Form"); // NOI18N
        setResizable(false);

        jPanel2.setName("jPanel2"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(fingerprintapplication.FingerprintApplication.class).getContext().getResourceMap(FingerprintForm.class);
        jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
        jButton4.setName("jButton4"); // NOI18N

        jButton5.setText(resourceMap.getString("jButton5.text")); // NOI18N
        jButton5.setName("jButton5"); // NOI18N
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel2.setForeground(resourceMap.getColor("jLabel2.foreground")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel2)
                    .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                    .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(471, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(20, 20, 20)
                .addComponent(jButton5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jimage.setName("jimage"); // NOI18N
        jimage.setPreferredSize(new java.awt.Dimension(500, 159));

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N

        jTextField1.setEditable(false);
        jTextField1.setMaximumSize(new java.awt.Dimension(6, 6));
        jTextField1.setName("jTextField1"); // NOI18N

        jTextField2.setEditable(false);
        jTextField2.setName("jTextField2"); // NOI18N

        jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout jimageLayout = new javax.swing.GroupLayout(jimage);
        jimage.setLayout(jimageLayout);
        jimageLayout.setHorizontalGroup(
            jimageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jimageLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jimageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jimageLayout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton3)
                        .addContainerGap(391, Short.MAX_VALUE))
                    .addGroup(jimageLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addContainerGap(521, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jimageLayout.createSequentialGroup()
                        .addGroup(jimageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE))
                        .addGap(217, 217, 217))))
        );
        jimageLayout.setVerticalGroup(
            jimageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jimageLayout.createSequentialGroup()
                .addContainerGap(12, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jimageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addContainerGap())
        );

        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N
        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 632, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jimage, javax.swing.GroupLayout.DEFAULT_SIZE, 632, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jimage, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        final JFileChooser fc = new JFileChooser();
        int returnVal = fc.showOpenDialog(FingerprintForm.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            //This is where a real application would open the file.
            putanja3="\\"+file.getName();



            try{
                m_bimage1=ImageIO.read(new File(new java.io.File("").getAbsolutePath()+putanja3)) ;
                m_panel1.setBufferedImage(m_bimage1);

                //Send image for skeletinization
                m_finger1.setFingerPrintImage(m_bimage1) ;
                finger1=m_finger1.getFingerPrintTemplate();
                //See what skeletinized image looks like
                m_bimage1 = m_finger1.getFingerPrintImageDetail();
                m_panel1.setBufferedImage(m_bimage1);
                // jTextField1.setText(m_finger1.ConvertFingerPrintTemplateDoubleToString(finger1));
                Sifra=m_finger1.ConvertFingerPrintTemplateDoubleToString(finger1);
                // Pretvaranje(Broj);
                //Sifra="ssssss";
                FingerprintApplication fa=new FingerprintApplication();

                //POMOCNA LINIJA+++++++++++++++ fa.startup();
                fa.podatak(Sifra);
                fa.startup();
                fa.getApplication();
                jToolBar1.remove(m_panel2);
                jToolBar1.repaint();
              // setVisible(true);
                jToolBar1.add(m_panel1);
                setVisible(true);
                // FingerprintView fw=new FingerprintView(this,Sifra);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null,ex.getMessage(),"Error",JOptionPane.PLAIN_MESSAGE);
            }
        }

        else {

        }


        //fa.startup();


        //FingerprintView fw=new FingerprintView(this);

        //fa.getApplication();
        //fa.main(fa);
}//GEN-LAST:event_jButton5ActionPerformed

    /**
    * @param args the command line arguments
    */
   /* public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FingerprintForm().setVisible(true);
            }
        });
    }*/

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JPanel jimage;
    // End of variables declaration//GEN-END:variables
 //uses our finger print libery
  private Fingerprint m_finger1 = new Fingerprint();
  private Fingerprint m_finger2 = new Fingerprint();
   private Fingerprint m_finger3 = new Fingerprint();
  private FingerprintGraphics m_fingergfx = new FingerprintGraphics();
 private BJPanel m_panel1 = new BJPanel();
  private BJPanel m_panel2 = new BJPanel();
  private BufferedImage m_bimage1 = new BufferedImage(m_finger1.FP_IMAGE_WIDTH ,m_finger1.FP_IMAGE_HEIGHT,BufferedImage.TYPE_INT_RGB );
  private BufferedImage m_bimage2 = new BufferedImage(m_finger2.FP_IMAGE_WIDTH ,m_finger2.FP_IMAGE_HEIGHT,BufferedImage.TYPE_INT_RGB );
  private double finger1[] = new double[m_finger1.FP_TEMPLATE_MAX_SIZE];
  private double finger2[] = new double[m_finger2.FP_TEMPLATE_MAX_SIZE];
  
 


public FingerprintForm() {
    
         initComponents();
         //Broj="163.0;247.0;179.0;0.0;0.0;0.0;0.0;62.0;-91.0;110.11357772772621;5.310466809756397;3.0;0.0;22.0;-20.0;29.732137494637012;5.545370247059122;1.0;0.0;59.0;-14.0;60.63827174318213;6.050206068102483;1.0;0.0;-33.0;-12.0;35.11409973215888;3.4903636571737002;3.0;0.0;-27.0;-12.0;29.546573405388315;3.5598169831690223;1.0;180.0;-3.0;-5.0;5.830951894845301;4.171969480114106;3.0;0.0;-19.0;2.0;19.1049731745428;-3.246469592320027;3.0;0.0;-27.0;25.0;36.796738985948195;-3.888548226966053;1.0;180.0;-26.0;41.0;48.54894437575342;-4.14723954037793;1.0;180.0;-42.0;46.0;62.289646009589745;-3.9724140964088184;1.0;180.0;-9.0;57.0;57.706152185014034;-4.5557871034026745;1.0;0.0;-44.0;59.0;73.60027173862879;-4.071605256207182;1.0;0.0;-12.0;61.0;62.16912416947821;-4.518147984203286;1.0;90.0;-12.0;61.0;62.16912416947821;-4.518147984203286;3.0;0.0;-7.0;65.0;65.37583651472461;-4.605110124736287;1.0;180.0;-63.0;76.0;98.71676655968832;-4.020244732092022;1.0;180.0;-40.0;78.0;87.65842800324451;-4.238537643889929;3.0;0.0;17.0;102.0;103.40696301506973;1.4056476493802699;1.0;90.0;55.0;115.0;127.47548783981962;1.124690777851493;1.0;0.0;-43.0;138.0;144.5441109142811;-4.410329534851561;1.0;270.0;-19.0;139.0;140.29255147726127;-4.576540239122898;1.0;0.0;-24.0;143.0;145.0;-4.546106516607807;1.0;90.0;-52.0;144.0;153.1012736720371;-4.365850115950748;1.0;90.0;-52.0;144.0;153.1012736720371;-4.365850115950748;3.0;0.0;59.0;164.0;174.28998823799375;1.2254566822927477;1.0;0.0;-1.0;167.0;167.0029939851379;-4.706401028000776;1.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0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.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;";

         //Pretvaranje(Broj);
         //Jpanel image=new JPanel();
//jimage.setbufferedimage();
   jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton1_actionPerformed(e);
      }
    });
    jButton2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton2_actionPerformed(e);
      }


    });
    jButton3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton3_actionPerformed(e);
      }
    });
    jButton4.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton4_actionPerformed(e);
      }
    });
 jButton5.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton5ActionPerformed(e);
      }
    });
 jToolBar1.setLayout(new GridLayout(1,1));
  //jToolBar1.add(jButton1);
  //jToolBar1.add(jButton2);
 //   jToolBar1.add(jButton3);
 //   jToolBar1.add(jButton4);
   // jToolBar1.add(jTextField1);
   //jToolBar1.add(jTextField2);

    try
    {
       


       // putanja="\\fingerprint.bmp";
    //picture1
    //Set picture new

  /* m_bimage1=ImageIO.read(new File(new java.io.File("").getAbsolutePath()+putanja)) ;
    m_panel1.setBufferedImage(m_bimage1);

    //Send image for skeletinization
    m_finger1.setFingerPrintImage(m_bimage1) ;
    finger1=m_finger1.getFingerPrintTemplate();
     //See what skeletinized image looks like
    m_bimage1 = m_finger1.getFingerPrintImageDetail();
    m_panel1.setBufferedImage(m_bimage1);
    */
//Broj="163.0;247.0;179.0;0.0;0.0;0.0;0.0;62.0;-91.0;110.11357772772621;5.310466809756397;3.0;0.0;22.0;-20.0;29.732137494637012;5.545370247059122;1.0;0.0;59.0;-14.0;60.63827174318213;6.050206068102483;1.0;0.0;-33.0;-12.0;35.11409973215888;3.4903636571737002;3.0;0.0;-27.0;-12.0;29.546573405388315;3.5598169831690223;1.0;180.0;-3.0;-5.0;5.830951894845301;4.171969480114106;3.0;0.0;-19.0;2.0;19.1049731745428;-3.246469592320027;3.0;0.0;-27.0;25.0;36.796738985948195;-3.888548226966053;1.0;180.0;-26.0;41.0;48.54894437575342;-4.14723954037793;1.0;180.0;-42.0;46.0;62.289646009589745;-3.9724140964088184;1.0;180.0;-9.0;57.0;57.706152185014034;-4.5557871034026745;1.0;0.0;-44.0;59.0;73.60027173862879;-4.071605256207182;1.0;0.0;-12.0;61.0;62.16912416947821;-4.518147984203286;1.0;90.0;-12.0;61.0;62.16912416947821;-4.518147984203286;3.0;0.0;-7.0;65.0;65.37583651472461;-4.605110124736287;1.0;180.0;-63.0;76.0;98.71676655968832;-4.020244732092022;1.0;180.0;-40.0;78.0;87.65842800324451;-4.238537643889929;3.0;0.0;17.0;102.0;103.40696301506973;1.4056476493802699;1.0;90.0;55.0;115.0;127.47548783981962;1.124690777851493;1.0;0.0;-43.0;138.0;144.5441109142811;-4.410329534851561;1.0;270.0;-19.0;139.0;140.29255147726127;-4.576540239122898;1.0;0.0;-24.0;143.0;145.0;-4.546106516607807;1.0;90.0;-52.0;144.0;153.1012736720371;-4.365850115950748;1.0;90.0;-52.0;144.0;153.1012736720371;-4.365850115950748;3.0;0.0;59.0;164.0;174.28998823799375;1.2254566822927477;1.0;0.0;-1.0;167.0;167.0029939851379;-4.706401028000776;1.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;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0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;";

       // JOptionPane.showMessageDialog(this, "asas","The Title",JOptionPane.INFORMATION_MESSAGE);
    
//String a= Integer.toString(m_finger1.ConvertFingerPrintTemplateDoubleToString(finger1));
    //jTextField1.setText(Broj);
   //finger3= ConvertFingerPrintTemplateStringToDouble(Broj);
    //jTextField1.setText(m_finger1.ConvertFingerPrintTemplateDoubleToString(finger1));

    //jTextField1.setText(m_finger1.ConvertFingerPrintTemplateDoubleToString(finger1));
//Broj=m_finger1.ConvertFingerPrintTemplateDoubleToString(finger1);
       
//picture2
    //Set picture new
  //  m_bimage2=ImageIO.read(new File(new java.io.File("").getAbsolutePath()+"\\ProcessedSample2.bmp")) ;



    /*

    m_bimage2=ImageIO.read(new File(new java.io.File("").getAbsolutePath()+"\\fingerprint.bmp")) ;
    m_panel2.setBufferedImage(m_bimage2);
    //Send image for skeletinization
    m_finger2.setFingerPrintImage(m_bimage2) ;
    finger2=m_finger2.getFingerPrintTemplate();
    //See what skeletinized image looks like
    m_bimage2 = m_finger2.getFingerPrintImageDetail();
    m_panel2.setBufferedImage(m_bimage2);
    jTextField2.setText(m_finger2.ConvertFingerPrintTemplateDoubleToString(finger2));


    */


//finger3=ConvertFingerPrintTemplateStringToDouble1(Broj);
//aDouble= Double.parseDouble(aString);
   // Pretvaranje(Broj);
    }
    catch (Exception ex)
    {
    JOptionPane.showMessageDialog (null,ex.getMessage(),"Error",JOptionPane.PLAIN_MESSAGE);
    }
    //this.getContentPane().setLayout(new GridLayout(1,1));
    //this.getContentPane().setLayout(new GridLayout(2,1));
   // this.getContentPane().setLayout(new );
   // this.getContentPane().add(m_panel1);
     //.add(m_panel1);
    //jimage.createImage(null);
   // this.getContentPane().add(m_panel2);
    //this.getContentPane().add(jToolBar1);
    //this.getContentPane().add(jButton1);
    //jPanel1.add(m_panel1);
   //this.getContentPane().add(m_panel1);
    //this.getContentPane().add(m_panel2);
   // jPanel1.setBackground(Color.LIGHT_GRAY);
    jPanel2.setBackground(Color.DARK_GRAY);
    //jPanel1.add(m_panel1);
   // m_panel1.add(jPanel1);
    //jPanel1.
    jimage.setBackground(Color.DARK_GRAY);
    this.setTitle("Fingerprint");
    //this.setSize(new Dimension(1024, 748)) ;
    


/*ImageIcon icon = new ImageIcon("C:\\Documents and Settings\\RazvojComp2\\My Documents\\NetBeansProjects\\FingerprintApplication\\fingerprint.jpg");
//ImageIcon icon = new ImageIcon();
//icon.getIconWidth(120);
jLabel3.setIcon(icon);

//this.getContentPane().add(jPanel1);

setVisible(true);*/
  }

   /*     @org.jdesktop.application.Action
    public void JButton1_actionperformed() {
    }*/

        //akcije/////////////////////////////////////////////////7
         private void jButton1_actionPerformed(ActionEvent e)
  {
             final JFileChooser fc = new JFileChooser();
             int returnVal = fc.showOpenDialog(FingerprintForm.this);
             if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            //This is where a real application would open the file.
            putanja="\\"+file.getName();
        } else {

        }
try{
 m_bimage1=ImageIO.read(new File(new java.io.File("").getAbsolutePath()+putanja)) ;
    m_panel1.setBufferedImage(m_bimage1);

    //Send image for skeletinization
    m_finger1.setFingerPrintImage(m_bimage1) ;
    finger1=m_finger1.getFingerPrintTemplate();
     //See what skeletinized image looks like
    m_bimage1 = m_finger1.getFingerPrintImageDetail();
    m_panel1.setBufferedImage(m_bimage1);
    jTextField1.setText(m_finger1.ConvertFingerPrintTemplateDoubleToString(finger1));
//Broj=m_finger1.ConvertFingerPrintTemplateDoubleToString(finger1);
 //Pretvaranje(Broj);
 /*ImageIcon icon = new ImageIcon("C:\\Documents and Settings\\RazvojComp2\\My Documents\\NetBeansProjects\\FingerprintApplication\\fingerprint.jpg");
JLabel label = new JLabel();
label.setIcon(icon);
jPanel1.add(label);*/
//ImageIcon icon = new ImageIcon("C:\\Documents and Settings\\RazvojComp2\\My Documents\\NetBeansProjects\\FingerprintApplication\\fingerprint.jpg");

    //ImageIcon icon = new ImageIcon(m_bimage1);
//jLabel3.setIcon(icon);
jToolBar1.add(m_panel1);
//this.getContentPane().add(m_panel1);
//this.getContentPane().add(jPanel1);

setVisible(true);
}
catch (Exception ex)
    {
    JOptionPane.showMessageDialog (null,ex.getMessage(),"Error",JOptionPane.PLAIN_MESSAGE);
    }
     //m_finger.ChaneLinkAlgorithm() ;
    //m_panel1.setBufferedImage(m_finger.getFingerPrintImage());
  }

  private void jButton2_actionPerformed(ActionEvent e)
  {
       final JFileChooser fc = new JFileChooser();
             int returnVal = fc.showOpenDialog(FingerprintForm.this);
             if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            //This is where a real application would open the file.
            putanja2="\\"+file.getName();
             }
             else {

        }
      try{
          m_bimage2=ImageIO.read(new File(new java.io.File("").getAbsolutePath()+putanja2)) ;
    m_panel2.setBufferedImage(m_bimage2);
    //Send image for skeletinization
    m_finger2.setFingerPrintImage(m_bimage2) ;
    finger2=m_finger2.getFingerPrintTemplate();
    //See what skeletinized image looks like
    m_bimage2 = m_finger2.getFingerPrintImageDetail();
    m_panel2.setBufferedImage(m_bimage2);
    jTextField2.setText(m_finger2.ConvertFingerPrintTemplateDoubleToString(finger2));
    jToolBar1.add(m_panel2);
    //this.getContentPane().add(m_panel2);
    setVisible(true);
      }
      /*try
      {
        m_bimage2=ImageIO.read(new File("/home/scott/JavaBiometrics/FingerPrintPic/Sample2.bmp")) ;
        //show original image
        m_panel1.setBufferedImage(m_bimage2);

       // m_bimage2 = m_fingergfx.getGreyFingerPrintImage(m_bimage2);
        m_bimage2 = m_fingergfx.BinerizeImage(m_bimage2, 250,180 );
        m_panel2.setBufferedImage(m_bimage2);
       }
       * */
      catch (Exception ex)
      {
         JOptionPane.showMessageDialog (null,ex.getMessage() ,"Error Message",JOptionPane.PLAIN_MESSAGE);
      }

  }

  private void jButton3_actionPerformed(ActionEvent e)
  {
      //match one print
     try
      {
        JOptionPane.showMessageDialog (null,Double.toString(m_finger1.Match(finger1 , finger2,65,false)),"Match %",JOptionPane.PLAIN_MESSAGE);
      }
      catch (Exception ex)
      {
      JOptionPane.showMessageDialog (null,ex.getMessage() ,"Error Message",JOptionPane.PLAIN_MESSAGE);
      }
  }

  private void jButton4_actionPerformed(ActionEvent e)
  {
      //match many finger prints
      //used to test matching speed
      //wors at about 1 match every 0,01 seconds needs to become a lot faster
      //the propriety software dose 1 match every 0,0001 a seconds
       FingerprintApplication fa=new FingerprintApplication();

                //POMOCNA LINIJA+++++++++++++++ fa.startup();
               // fa.podatak(Sifra);

       //         fa.startup();
                fa.getApplication();
        // List<fingerprintapplication.Persons> toRemove = new ArrayList<fingerprintapplication.Persons>(selected.length);
      //Persons person=new Persons();

      //Ime=person.getIme();
      JOptionPane.showMessageDialog(this, Ime,"The Title",JOptionPane.INFORMATION_MESSAGE);

     /* try
      {
          long res = System.currentTimeMillis();
         for (int i = 0;i<=500;i++)
            {
                m_finger1.Match(finger1 , finger2,55,true);
                if (i == 500)
                {
                res=(System.currentTimeMillis()-res)/1000;
                JOptionPane.showMessageDialog (null, Long.toString(res),"Time to do 500 matches",JOptionPane.PLAIN_MESSAGE);
                }
            }
      }
      catch (Exception ex)
      {
      JOptionPane.showMessageDialog (null,ex.getMessage() ,"Error Message",javax.swing.JOptionPane.PLAIN_MESSAGE);
      }*/
  }
  public void Pretvaranje(String Broj)
  {
      finger3= ConvertFingerPrintTemplateStringToDouble1(Broj);
  };
public double [] ConvertFingerPrintTemplateStringToDouble1(String finger)
  {
   /* JOptionPane.showMessageDialog(this,
                                    finger,
                                    "The Title",
                                    JOptionPane.INFORMATION_MESSAGE);*/
        double m_finger[] = new double[FP_TEMPLATE_MAX_SIZE];
        int c=0;
        String m_double = "";
        String temp ="";
        for (int i=0;i<=finger.length()-1 ; i++)
        {
           temp = Character.toString(finger.charAt(i));

           if (temp.equals(";"))
           {
               /*JOptionPane.showMessageDialog(this,
                                    temp,
                                    "The Title",
                                    JOptionPane.INFORMATION_MESSAGE);*/
                m_finger[c++] = Double.parseDouble(m_double);
                m_double="";
               


           }
           else
           {
               /* JOptionPane.showMessageDialog(this,
                                    finger.charAt(i),
                                    "The Title",
                                    JOptionPane.INFORMATION_MESSAGE);
               */
                m_double  = m_double +  temp;
                /*JOptionPane.showMessageDialog(this,
                                    m_double,
                                    "The Title",
                                    JOptionPane.INFORMATION_MESSAGE);
                */
           }
        }
    return m_finger;
  }
  //kraj akcija
public void setBufferedImage(BufferedImage bi)
    {
      this.bi = bi;
      setPreferredSize(new Dimension(bi.getWidth(),bi.getHeight())) ;
      this.repaint();
    }


}